package com.ruoyi.web.controller.bussiness;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.entity.po.TPlayerTweets;
import com.ruoyi.service.TPlayerTweetsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 选手动态(t_player_tweets)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/playerTweets")
@Api(tags = "PC-6.选手动态管理")
public class PlayerTweetsController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private TPlayerTweetsService playerTweetsService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    @ApiOperation("查询选手动态")
    public TPlayerTweets selectOne(Integer id) {
        return playerTweetsService.selectByPrimaryKey(id);
    }

    @GetMapping("/list")
    @ApiOperation("查询选手动态列表")
    public TableDataInfo list(TPlayerTweets playerTweets) {
        startPage();
        List<TPlayerTweets> list = playerTweetsService.selectTweetsList(playerTweets);
        return getDataTable(list);
    }

    @PostMapping("/add")
    @ApiOperation("新增选手动态")
    public AjaxResult add(@RequestBody TPlayerTweets playerTweets) {
        return toAjax(playerTweetsService.insertSelective(playerTweets));
    }

    @PostMapping("/delete")
    @ApiOperation("删除选手动态")
    public AjaxResult delete(@RequestBody Integer[] ids) {
        return toAjax(playerTweetsService.deleteByPrimaryKeys(ids));
    }

    @PostMapping("/edit")
    @ApiOperation("修改选手动态")
    public AjaxResult edit(@RequestBody TPlayerTweets playerTweets) {
        return toAjax(playerTweetsService.updateByPrimaryKeySelective(playerTweets));
    }

}
